<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<div style="width:900px; margin:0px auto">
  <h3 style="width:900px; margin:0px auto; text-align:center">图书信息类别</h3>
        <div style="width:900px; margin:0px auto; text-align:center; line-height:35px; height:35px">
        
        <form action="BookInfoServlet" method="post" id="form1">
        
        <!-- 使用隐藏的input携带pageNo -->
        <input type="hidden" id="pageNo" name="pageNo">
        图书分类：
         
          <select name="typeId" id="typeId">
            <option value="-1">全部</option>
            <c:if test="${typeList != null}">
            	<c:forEach items="${typeList}" var="bookType">
            	
            		<option 
            			<c:if test="${map.typeID == bookType.typeID }">
            			selected = "selected"
            			</c:if>
            		value="${bookType.typeID}">${bookType.typeName}</option>
            	</c:forEach>
            </c:if>
          </select>
         
        图书名称：
        
        <input type="text" name="bookName" id="bookName" />
        
    
       
        <input name="radio" type="radio" id="isBorrow3" value="isBorrow" checked="checked" />
        全部
    
        <input type="submit" name="btnQuery" id="btnQuery" value="查询" />
        
        </form>
        
        </div>
  <div style="width:850px; margin:0px auto; text-align:right; line-height:35px; height:35px; padding-right:50px">
  <a href="PreAddBookServlet">添加</a>&nbsp; &nbsp;
  <a href="/book/PreAddBookServlet">删除所选</a> 
   </div>
        <table width="1000" border="1">
          <tr>
          	<td width="59"><label>
          	  <input type="checkbox" name="cbkAll" id="cbkAll" />
          	  全选
          	</label></td>
            <td width="40">图书编号</td>
            <td width="94">图书分类</td>
            <td width="100">图书名称</td>
            <td width="100">图书创建时间</td>
            <td width="200">图书封面</td>
            <td width="71">操作</td>
            <td width="48">详细</td>
            <td width="48">删除</td>
            <td width="60">修改</td>
          </tr>
  				<c:if test="${pageUtil.list != null}">
  					<c:forEach items="${pageUtil.list}" var = "bookInfo">
	  					 <tr>
				          	<td width="59"><label>
				          	<input type="checkbox" name="cbk" id="cbk" value="${bookInfo.bookId}"/>
				          	  全选
				          	</label></td>
				            <td width="40">${bookInfo.bookId}</td>
				            <td width="94">${bookInfo.bookType.typeName}</td>
				            <td width="100">${bookInfo.bookName}</td>
				            <td width="100"><fmt:formatDate value="${bookInfo.createDate}" pattern="yyyy年MM月dd日"/> </td>
				            <td width="200" ><img height="50px" src="${pageContext.request.contextPath}${bookInfo.img}"></td>
				            <td width="71">操作</td>
				            <td width="48">详细</td>
				            <td width="48" ><a href="javascript:deleteBook(${bookInfo.bookId})">删除</a></td>
				            <td width="60">修改</td>
	         			 </tr>
  					
  					</c:forEach>
  				
  				</c:if>
          <tr>
            <td colspan="10" align="center">
            <a href="javascript:doPage(1)">首页</a>&nbsp;
             <a href="javascript:doPage(${pageUtil.pageNo-1})">上一页</a>&nbsp;
             <a href="javascript:doPage(${pageUtil.pageNo+1})">下一页</a>&nbsp;
            <a href="javascript:doPage(${pageUtil.pageTota})">末页</a>&nbsp;&nbsp;
          ${pageUtil.pageNo}/${pageUtil.pageTota}页
             &nbsp;
              <input name="pageNumber" type="text" id="pageNumber" size="5" />
              <input type="button" name="btnQuery2" id="btnQuery2" value="GO" />            </td>
          </tr>
        </table>
  </div>
  <script type="text/javascript">
		 	function deleteBook(bookId){
				var flag = confirm("确定要删除这条记录么？");
				if(flag){
					window.location.href="http://localhost/jsp_06/DeleteServlet?bookId="+bookId;
				}
			}
			function doPage(pageNo){
				//将 传递 进来 的 pageNo 赋值给 隐藏的 input ，提交时  就携带到了后端
				document.getElementById("pageNo").value=pageNo;
				//执行 提交 方法 
				document.getElementById("form1").submit();
			}
  </script>
</body>
</html>